﻿using MvvmUtils.ViewModels;

namespace MvvmUtils.Tests.ViewModels.Mocks
{
    public class MainViewModel : ViewModel
    {
        private readonly ComputedProperty<MainViewModel, string> _path;

        private readonly Property<string> _stringProperty;

        public MainViewModel()
        {
            _stringProperty = new Property<string>("StringProperty", this);
            _path = this.Computed(
                vm => vm.Path,
                vm =>
                string.Format(
                    "{0}.{1}.{2}",
                    vm.SelectedMaster.Name,
                    vm.SelectedMaster.SelectedDetail.Name,
                    vm.SelectedMaster.SelectedDetail.SelectedSubDetail.Name));
        }

        public MasterViewModel SelectedMaster { get; set; }

        public string StringProperty
        {
            get { return _stringProperty.GetValue(); }
            set { _stringProperty.SetValue(value); }
        }

        public string Path
        {
            get { return _path.GetValue(); }
        }
    }

    public class MasterViewModel : ViewModel
    {
        private readonly Property<string> _name;

        public MasterViewModel()
        {
            _name = new Property<string>("Name", this);
        }

        public string Name
        {
            get { return _name.GetValue(); }
            set { _name.SetValue(value); }
        }

        public DetailViewModel SelectedDetail { get; set; }
    }

    public class DetailViewModel : ViewModel
    {
        private readonly Property<string> _name;

        public DetailViewModel()
        {
            _name = new Property<string>("Name", this);
        }

        public string Name
        {
            get { return _name.GetValue(); }
            set { _name.SetValue(value); }
        }

        public SubDetailViewModel SelectedSubDetail { get; set; }
    }

    public class SubDetailViewModel : ViewModel
    {
        private readonly Property<string> _name;

        public SubDetailViewModel()
        {
            _name = new Property<string>("Name", this);
        }

        public string Name
        {
            get { return _name.GetValue(); }
            set { _name.SetValue(value); }
        }
    }
}